//
//  HyperlinksController.m
//  shike
//
//  Created by RegentSoft on 2017/4/20.
//  Copyright © 2017年 RegentSoft. All rights reserved.

//超链接
#import "HyperlinksController.h"

@interface HyperlinksController ()<UIWebViewDelegate>{
    UIWindow * window;
    UIWebView *webViewURL;
    NSString * urlString;
}
@end
MBProgressHUD * HUD;
@implementation HyperlinksController
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    window = [[UIApplication sharedApplication] keyWindow];
    HUD = [MBProgressHUD showHUDAddedTo:window animated:YES];
    HUD.labelText = @"loading...";
    [window addSubview:HUD];
    [HUD show:YES];
    webViewURL = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    webViewURL.delegate = self;
    webViewURL.backgroundColor = [UIColor clearColor];
    webViewURL.scalesPageToFit = YES;
    urlString =@"http://120.77.252.204/wap?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjRkOThjM2JhMDdjYzIwZDJlMjM1NDAxOTY1NDg2MzllMTJkM2EzMjcxNjdmMjEzMDk2ZDM5ZGJjM2Q5ZWY1Y2UzNjMwYjhlZDI3MmE0ZDg2In0.eyJhdWQiOiIyIiwianRpIjoiNGQ5OGMzYmEwN2NjMjBkMmUyMzU0MDE5NjU0ODYzOWUxMmQzYTMyNzE2N2YyMTMwOTZkMzlkYmMzZDllZjVjZTM2MzBiOGVkMjcyYTRkODYiLCJpYXQiOjE0OTI1NzI2MzUsIm5iZiI6MTQ5MjU3MjYzNSwiZXhwIjoxNDkzODY4NjM1LCJzdWIiOiI4NmQzMGFiYzI0YWUxMWU3YjI1MjAwMTYzZTAyYzA3MiIsInNjb3BlcyI6W119.dqs_57XRkeU_l1Qe4NdHp462dPK6XU22EEAzcaxwg4sOd4csb-noOQRQ0Dwgpo_yjv0jR6B-iAGGibQ_BRcrWkmNZqt28oLXGw5yWZuTNvNLPB-Fiwf0xkLAsXPoZqz8ZDCjs5fM_f0xRWroUTXaskc2FqEChvSSY0lNzEAE1vh5R0SZycdT_N-RKkBETVO50Y_IRIgU88sJruxvlg8N9LFIbXn7IaEuff-BZqEM9IMBgyoic4fIjJN5WQCi7-eLf-SbYT2FvJZ3HF-4Ys6ozbGA-fQq823-tioVi7GxG2gi2VXRJcbsJ-yYq5C6a6TDFS14BvehXaRZ4uxLfFLMIuZmfWLQOvcPGNpSVoll7Gc6pIWHsw2o6x3JsFFOOOzKwtx8-FOqBeJ_xejEIjDrthTNv8ejkJcmi2v74gNxHKyGMVuvEkTLB-MsrdC4ChyvgMGCjeLpPkahiYqc41wxm-6cKZPSYvH-vLc7nPRMhLarwp-nPbF9NsKzMTmRIAIjt0AxnjYatOc7140J0qam9gp1i6M1BkuMzCKmjBaJxAcz9Mzkn0eIvobU7a5MAitk5GOqRwLYQ9w_V_hiTGO-9u1RoyrP1BvKYfwxf7RBfReDkk4Ug_VLYlTAACAAIWm7I21cSgqqXvCZbhukX8G18fGHL4x7bJ1FSm818oy7jow";
    NSURL *url =[NSURL URLWithString:[NSString stringWithFormat:@"%@",urlString]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    request.cachePolicy = NSURLRequestReturnCacheDataElseLoad;
    [webViewURL loadRequest:request];
    [self.view addSubview:webViewURL];

}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    HUD.hidden = YES;
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    
    if([error code] == NSURLErrorCancelled){
        return;
    }else{
        UIAlertView * alert = [[UIAlertView alloc] initWithTitle:nil message:error.localizedDescription delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alert show];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
